package com.hnevc.loginregistershiqinwen;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;


public class RegisterActivity extends Activity {
    private static final String TAG = "RegisterActivity";
    EditText username;
    EditText password;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register_activity);
        //获取控件
        username = findViewById(R.id.etRegisterUserName);
        password = findViewById(R.id.etRegisterPassword);

    }

    //注册
    public void setRegister(View view) {
        //使用SharedPreferences储存
        SharedPreferences.Editor editor = getSharedPreferences("data", MODE_PRIVATE).edit();
        editor.putString("name", username.getText().toString());
        editor.putString("password", password.getText().toString());
        editor.commit();
        //提示
        Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_LONG).show();
        //跳回登录
        Intent intent = new Intent();
        intent.setClass(RegisterActivity.this, MainActivity.class);
        startActivity(intent);
        finish();

    }
}
